;; Use theme
(load-theme 'solarized-dark 1)

;; Disable tool bar
(tool-bar-mode -1)

;;
(tooltip-mode -1)

;; Disable scroll bar
(scroll-bar-mode -1)

;; Disable menu bar
(menu-bar-mode -1)

;; High light current line
(global-hl-line-mode 1)

;; High light current line number
;;  (hlinum-activate)

;; linum mode
(require 'damacs-line-numbers)
;; (display-line-numbers-mode 1)

;; column number
(column-number-mode 1)

;; hidden mouse when type
(setq make-pointer-invisible t)

;; Set fonts
;; (add-to-list 'default-frame-alist '(font . "Source Code Pro"))
;; (add-to-list 'default-frame-alist '(height . 24))
;; (add-to-list 'default-frame-alist '(width . 80))
;; (require 'font-lock)
;; (set-default-font "Source Code Pro 12")
;; (set-fontset-font "fontset-default" 'unicode "WenQuanYi Micro Hei Mono 15");
;; (setq face-font-rescale-alist '(
;;                                 ("WenQuanYi Micro Hei Mono" . 1.3)
;;                                 ))

;; Clean scratch buffer
;; (setq initial-scratch-message "")

;; Change cursor type
;; (modify-all-frames-parameters
;;  (list (cons 'cursor-type '(bar . 10))))

;; High light whitespace
;; (setq whitespace-style '(face tabs trailing tab-mark))
;; (setq whitespace-display-mappings
;;       '((space-mark 32 [32] [183] [46])
;;         (space-mark 160 [164] [95])
;;         (space-mark 2208 [2212] [95])
;;         (space-mark 2336 [2340] [95])
;;         (space-mark 3616 [3620] [95])
;;         (space-mark 3872 [3876] [95])
;;         (newline-mark 10 [182 10] [36 10])
;;         (tab-mark 9 [187 9] [92 9])))
;; (global-whitespace-mode t)

;; Full Screen Setting From Lazycat
;; Add fullscreen in damacs-modules-dir
;; https://github.com/manateelazycat/lazycat-emacs/blob/master/site-lisp/config/init-startup.el
(require 'fullscreen)
(if (featurep 'cocoa)
    (progn
      ;; 在Mac平台, Emacs不能进入Mac原生的全屏模式,否则会导致 `make-frame' 创建时也集成原生全屏属性后造成白屏和左右滑动现象.
      ;; 所以先设置 `ns-use-native-fullscreen' 和 `ns-use-fullscreen-animation' 禁止Emacs使用Mac原生的全屏模式.
      ;; 而是采用传统的全屏模式, 传统的全屏模式, 只会在当前工作区全屏,而不是切换到Mac那种单独的全屏工作区,
      ;; 这样执行 `make-frame' 先关代码或插件时,就不会因为Mac单独工作区左右滑动产生的bug.
      ;;
      ;; Mac平台下,不能直接使用 `set-frame-parameter' 和 `fullboth' 来设置全屏,
      ;; 那样也会导致Mac窗口管理器直接把Emacs窗口扔到单独的工作区, 从而对 `make-frame' 产生同样的Bug.
      ;; 所以, 启动的时候通过 `set-frame-parameter' 和 `maximized' 先设置Emacs为最大化窗口状态, 启动5秒以后再设置成全屏状态,
      ;; Mac就不会移动Emacs窗口到单独的工作区, 最终解决Mac平台下原生全屏窗口导致 `make-frame' 左右滑动闪烁的问题.
      (setq ns-use-native-fullscreen nil)
      (setq ns-use-fullscreen-animation nil)
      (run-at-time "5sec" nil
                   (lambda ()
                     (let ((fullscreen (frame-parameter (selected-frame) 'fullscreen)))
                       ;; If emacs has in fullscreen status, maximized window first, drag emacs window from Mac's single space.
                       (when (memq fullscreen '(fullscreen fullboth))
                         (set-frame-parameter (selected-frame) 'fullscreen 'maximized))
                       ;; Call `toggle-frame-fullscreen' to fullscreen emacs.
                       (toggle-frame-fullscreen)))))

  ;; 非Mac平台直接全屏
  (require 'fullscreen)
  (fullscreen))

(setq ad-redefinition-action 'accept)   ;不要烦人的 redefine warning
(setq frame-resize-pixelwise t) ;设置缩放的模式,避免Mac平台最大化窗口以后右边和下边有空隙
(server-start)                  ;为emacsclient准备使用场景，比如git

;; Show window number
(require 'window-numbering)
(window-numbering-mode t)

;; display time in mode line
;; (setq display-time-format "%d.%m %H:%M ")
;; (setq display-time-default-load-average nil)
;; (setq display-time-interval 1)
;; (display-time)

;; Startup sceen
(setq inhibit-startup-screen t)
(setq initial-scratch-message "Welecom My Captain 400dama")

;; modeline
(require 'damacs-modeline)

;; display battery status
(display-battery-mode t)


;; (display-time-mode t)
;; (setq display-time-default-load-average nil)
;; (setq display-time-24hr-format t)
;; (setq system-time-locale "C")
;; (defun custom-modeline-time ()
;;   (let* ((hour (string-to-number (format-time-string "%I")))
;;          (icon (all-the-icons-wicon (format "time-%s" hour) :height 1.3 :v-adjust 0.0)))
;;     (concat
;;      (propertize (format-time-string " %H:%M ") 'face `(:height 0.9))
;;      (propertize (format "%s " icon) 'face `(:height 1.0 :family ,(all-the-icons-wicon-family)) 'display '(raise -0.0)))))
;; (setq mode-line-format '("%e" (:eval
;;   (concat
;;     (custom-modeline-time)))))


(provide 'damacs-ui)
